package org.yagnus.stats.summary.univariate;

/**
 * 
 * Macro average of n weighted values x_i and respective weights w_i, is
 * 
 * \sum{x_i / w_i} / n
 * 
 * @author u
 * 
 */
public class MacroAverage extends UnivariateWeightedSummaryStatistic<Double> {

	WeightedAverage wa = new WeightedAverage();

	public MacroAverage() {
		clear();
	}

	@Override
	public void clear() {
		wa.clear();
	}

	@Override
	public Double get() {
		return wa.get();
	}

	@Override
	public void add(Double data, double weight) {
		if (weight > 0)
			wa.add(data, 1 / weight);
		else
			wa.add(data, 0);
	}

}
